<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>Linux 命令- diff | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>Linux 命令- diff</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux命令/">Linux命令</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;diff 命令是 linux上非常重要的工具，用于比较文件的内容，特别是比较两个版本不同的文件以找到改动的地方。diff在命令行中打印每一个行的改动。最新版本的diff还支持二进制文件。diff程序的输出被称为补丁 (patch)，因为Linux系统中还有一个patch程序，可以根据diff的输出将a.c的文件内容更新为b.c。diff是svn、cvs、git等版本控制工具不可或缺的一部分。</p>
<h2 id="1．命令格式"><a href="#1．命令格式" class="headerlink" title="1．命令格式"></a>1．命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff [参数] [文件1或目录1] [文件2或目录2]</div></pre></td></tr></table></figure>
<h2 id="2．命令功能"><a href="#2．命令功能" class="headerlink" title="2．命令功能"></a>2．命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;diff命令能比较单个文件或者目录内容。如果指定比较的是文件，则只有当输入为文本文件时才有效。以逐行的方式，比较文本文件的异同处。如果指定比较的是目录的的时候，diff 命令会比较两个目录下名字相同的文本文件。列出不同的二进制文件、公共子目录和只在一个目录出现的文件。</p>
<h2 id="3．命令参数："><a href="#3．命令参数：" class="headerlink" title="3．命令参数："></a>3．命令参数：</h2><ul>
<li><ul>
<li>　指定要显示多少行的文本。此参数必须与-c或-u参数一并使用。</li>
</ul>
</li>
<li>-a或–text 　diff预设只会逐行比较文本文件。</li>
<li>-b或–ignore-space-change 　不检查空格字符的不同。</li>
<li>-B或–ignore-blank-lines 　不检查空白行。</li>
<li>-c 　显示全部内文，并标出不同之处。</li>
<li>-C或–context 　与执行”-c-“指令相同。</li>
<li>-d或–minimal 　使用不同的演算法，以较小的单位来做比较。</li>
<li>-D或ifdef 　此参数的输出格式可用于前置处理器巨集。</li>
<li>-e或–ed 　此参数的输出格式可用于ed的script文件。</li>
<li>-f或-forward-ed 　输出的格式类似ed的script文件，但按照原来文件的顺序来显示不同处。</li>
<li>-H或–speed-large-files 　比较大文件时，可加快速度。</li>
<li>-l或–ignore-matching-lines 　若两个文件在某几行有所不同，而这几行同时都包含了选项中指定的字符或字符串，则不显示这两个文件的差异。</li>
<li>-i或–ignore-case 　不检查大小写的不同。</li>
<li>-l或–paginate 　将结果交由pr程序来分页。</li>
<li>-n或–rcs 　将比较结果以RCS的格式来显示。</li>
<li>-N或–new-file 　在比较目录时，若文件A仅出现在某个目录中，预设会显示：Only in目录：文件A若使用-N参数，则diff会将文件A与一个空白的文件比较。</li>
<li>-p 　若比较的文件为C语言的程序码文件时，显示差异所在的函数名称。</li>
<li>-P或–unidirectional-new-file 　与-N类似，但只有当第二个目录包含了一个第一个目录所没有的文件时，才会将这个文件与空白的文件做比较。</li>
<li>-q或–brief 　仅显示有无差异，不显示详细的信息。</li>
<li>-r或–recursive 　比较子目录中的文件。</li>
<li>-s或–report-identical-files 　若没有发现任何差异，仍然显示信息。</li>
<li>-S或–starting-file 　在比较目录时，从指定的文件开始比较。</li>
<li>-t或–expand-tabs 　在输出时，将tab字符展开。</li>
<li>-T或–initial-tab 　在每行前面加上tab字符以便对齐。</li>
<li>-u,-U或–unified= 　以合并的方式来显示文件内容的不同。</li>
<li>-v或–version 　显示版本信息。</li>
<li>-w或–ignore-all-space 　忽略全部的空格字符。</li>
<li>-W或–width 　在使用-y参数时，指定栏宽。</li>
<li>-x或–exclude 　不比较选项中所指定的文件或目录。</li>
<li>-X或–exclude-from 　您可以将文件或目录类型存成文本文件，然后在=中指定此文本文件。</li>
<li>-y或–side-by-side 　以并列的方式显示文件的异同之处。</li>
<li>–help 　显示帮助。</li>
<li>–left-column 　在使用-y参数时，若两个文件某一行内容相同，则仅在左侧的栏位显示该行内容。</li>
<li>–suppress-common-lines 　在使用-y参数时，仅显示不同之处。</li>
</ul>
<h2 id="4．使用实例："><a href="#4．使用实例：" class="headerlink" title="4．使用实例："></a>4．使用实例：</h2><h3 id="实例1：比较两个文件"><a href="#实例1：比较两个文件" class="headerlink" title="实例1：比较两个文件"></a>实例1：比较两个文件</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff log2014.log log2013.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># diff log2014.log log2013.log </span></div><div class="line">3c3</div><div class="line">&lt; 2014-03</div><div class="line">---</div><div class="line">&gt; 2013-03</div><div class="line">8c8</div><div class="line">&lt; 2013-07</div><div class="line">---</div><div class="line">&gt; 2013-08</div><div class="line">11,12d10</div><div class="line">&lt; 2013-11</div><div class="line">&lt; 2013-12</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;上面的“3c3”和“8c8”表示log2014.log和log20143log文件在3行和第8行内容有所不同；”11,12d10”表示第一个文件比第二个文件多了第11和12行。</p>
<h4 id="diff-的normal-显示格式有三种提示"><a href="#diff-的normal-显示格式有三种提示" class="headerlink" title="diff 的normal 显示格式有三种提示:"></a>diff 的normal 显示格式有三种提示:</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;a - add</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;c - change</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;d - delete </p>
<h3 id="实例2：并排格式输出"><a href="#实例2：并排格式输出" class="headerlink" title="实例2：并排格式输出"></a>实例2：并排格式输出</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff log2013.log log2014.log  -y -W 50</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># diff log2014.log log2013.log  -y -W 50</span></div><div class="line">2013-01                 2013-01</div><div class="line">2013-02                 2013-02</div><div class="line">2014-03               | 2013-03</div><div class="line">2013-04                 2013-04</div><div class="line">2013-05                 2013-05</div><div class="line">2013-06                 2013-06</div><div class="line">2013-07                 2013-07</div><div class="line">2013-07               | 2013-08</div><div class="line">2013-09                 2013-09</div><div class="line">2013-10                 2013-10</div><div class="line">2013-11               &lt;</div><div class="line">2013-12               &lt;</div><div class="line">[root@localhost test3]<span class="comment"># diff log2013.log log2014.log  -y -W 50</span></div><div class="line">2013-01                 2013-01</div><div class="line">2013-02                 2013-02</div><div class="line">2013-03               | 2014-03</div><div class="line">2013-04                 2013-04</div><div class="line">2013-05                 2013-05</div><div class="line">2013-06                 2013-06</div><div class="line">2013-07                 2013-07</div><div class="line">2013-08               | 2013-07</div><div class="line">2013-09                 2013-09</div><div class="line">2013-10                 2013-10</div><div class="line">                      &gt; 2013-11</div><div class="line">                      &gt; 2013-12</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“|”表示前后2个文件内容有不同</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“&lt;”表示后面文件比前面文件少了1行内容</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“&gt;”表示后面文件比前面文件多了1行内容</p>
<h3 id="实例3：上下文输出格式"><a href="#实例3：上下文输出格式" class="headerlink" title="实例3：上下文输出格式"></a>实例3：上下文输出格式</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff log2013.log log2014.log  -c</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># diff log2013.log log2014.log  -c</span></div><div class="line">*** log2013.log 2012-12-07 16:36:26.000000000 +0800</div><div class="line">--- log2014.log 2012-12-07 18:01:54.000000000 +0800</div><div class="line">***************</div><div class="line">*** 1,10 ****</div><div class="line">  2013-01</div><div class="line">  2013-02</div><div class="line">! 2013-03</div><div class="line">  2013-04</div><div class="line">  2013-05</div><div class="line">  2013-06</div><div class="line">  2013-07</div><div class="line">! 2013-08</div><div class="line">  2013-09</div><div class="line">  2013-10</div><div class="line">--- 1,12 ----</div><div class="line">  2013-01</div><div class="line">  2013-02</div><div class="line">! 2014-03</div><div class="line">  2013-04</div><div class="line">  2013-05</div><div class="line">  2013-06</div><div class="line">  2013-07</div><div class="line">! 2013-07</div><div class="line">  2013-09</div><div class="line">  2013-10</div><div class="line">+ 2013-11</div><div class="line">+ 2013-12[root@localhost test3]<span class="comment"># diff log2014.log log2013.log  -c</span></div><div class="line">*** log2014.log 2012-12-07 18:01:54.000000000 +0800</div><div class="line">--- log2013.log 2012-12-07 16:36:26.000000000 +0800</div><div class="line">***************</div><div class="line">*** 1,12 ****</div><div class="line">  2013-01</div><div class="line">  2013-02</div><div class="line">! 2014-03</div><div class="line">  2013-04</div><div class="line">  2013-05</div><div class="line">  2013-06</div><div class="line">  2013-07</div><div class="line">! 2013-07</div><div class="line">  2013-09</div><div class="line">  2013-10</div><div class="line">- 2013-11</div><div class="line">- 2013-12</div><div class="line">--- 1,10 ----</div><div class="line">  2013-01</div><div class="line">  2013-02</div><div class="line">! 2013-03</div><div class="line">  2013-04</div><div class="line">  2013-05</div><div class="line">  2013-06</div><div class="line">  2013-07</div><div class="line">! 2013-08</div><div class="line">  2013-09</div><div class="line">  2013-10[root@localhost test3]<span class="comment">#</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;这种方式在开头两行作了比较文件的说明，这里有三中特殊字符：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“＋” 比较的文件的后者比前着多一行</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“－” 比较的文件的后者比前着少一行</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;“！” 比较的文件两者有差别的行</p>
<h3 id="实例4：统一格式输出"><a href="#实例4：统一格式输出" class="headerlink" title="实例4：统一格式输出"></a>实例4：统一格式输出</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff log2014.log log2013.log  -u</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># diff log2014.log log2013.log  -u</span></div><div class="line">--- log2014.log 2012-12-07 18:01:54.000000000 +0800</div><div class="line">+++ log2013.log 2012-12-07 16:36:26.000000000 +0800</div><div class="line">@@ -1,12 +1,10 @@</div><div class="line"> 2013-01</div><div class="line"> 2013-02</div><div class="line">-2014-03</div><div class="line">+2013-03</div><div class="line"> 2013-04</div><div class="line"> 2013-05</div><div class="line"> 2013-06</div><div class="line"> 2013-07</div><div class="line">-2013-07</div><div class="line">+2013-08</div><div class="line"> 2013-09</div><div class="line"> 2013-10</div><div class="line">-2013-11</div><div class="line">-2013-12</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;它的第一部分，也是文件的基本信息：</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;— log2014.log 2012-12-07 18:01:54.000000000 +0800</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;+++ log2013.log 2012-12-07 16:36:26.000000000 +0800</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;”—“表示变动前的文件，”+++”表示变动后的文件。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;第二部分，变动的位置用两个@作为起首和结束。</p>
<p>@@ -1,12 +1,10 @@</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;前面的”-1,12”分成三个部分：减号表示第一个文件（即log2014.log），”1”表示第1行，”12”表示连续12行。合在一起，就表示下面是第一个文件从第1行开始的连续12行。同样的，”+1,10”表示变动后，成为第二个文件从第1行开始的连续10行。</p>
<h3 id="实例5：比较文件夹不同"><a href="#实例5：比较文件夹不同" class="headerlink" title="实例5：比较文件夹不同"></a>实例5：比较文件夹不同</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff  test3 test6</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># diff test3 test6</span></div><div class="line">Only <span class="keyword">in</span> test6: linklog.log</div><div class="line">Only <span class="keyword">in</span> test6: log2012.log</div><div class="line">diff test3/log2013.log test6/log2013.log</div><div class="line">1,10c1,3</div><div class="line">&lt; 2013-01</div><div class="line">&lt; 2013-02</div><div class="line">&lt; 2013-03</div><div class="line">&lt; 2013-04</div><div class="line">&lt; 2013-05</div><div class="line">&lt; 2013-06</div><div class="line">&lt; 2013-07</div><div class="line">&lt; 2013-08</div><div class="line">&lt; 2013-09</div><div class="line">&lt; 2013-10</div><div class="line">---</div><div class="line">&gt; hostnamebaidu=baidu.com</div><div class="line">&gt; hostnamesina=sina.com</div><div class="line">&gt; hostnames=<span class="literal">true</span></div><div class="line">diff test3/log2014.log test6/log2014.log</div><div class="line">1,12d0</div><div class="line">&lt; 2013-01</div><div class="line">&lt; 2013-02</div><div class="line">&lt; 2014-03</div><div class="line">&lt; 2013-04</div><div class="line">&lt; 2013-05</div><div class="line">&lt; 2013-06</div><div class="line">&lt; 2013-07</div><div class="line">&lt; 2013-07</div><div class="line">&lt; 2013-09</div><div class="line">&lt; 2013-10</div><div class="line">&lt; 2013-11</div><div class="line">&lt; 2013-12</div><div class="line">Only <span class="keyword">in</span> test6: log2015.log</div><div class="line">Only <span class="keyword">in</span> test6: log2016.log</div><div class="line">Only <span class="keyword">in</span> test6: log2017.log</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例6：比较两个文件不同，并生产补丁"><a href="#实例6：比较两个文件不同，并生产补丁" class="headerlink" title="实例6：比较两个文件不同，并生产补丁"></a>实例6：比较两个文件不同，并生产补丁</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">diff -ruN log2013.log log2014.log &gt;patch.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># diff -ruN log2013.log log2014.log &gt;patch.log</span></div><div class="line">[root@localhost test3]<span class="comment"># ll</span></div><div class="line">总计 12</div><div class="line">-rw-r--r-- 2 root root  80 12-07 16:36 log2013.log</div><div class="line">-rw-r--r-- 1 root root  96 12-07 18:01 log2014.log</div><div class="line">-rw-r--r-- 1 root root 248 12-07 21:33 patch.log</div><div class="line">[root@localhost test3]<span class="comment"># cat patc.log</span></div><div class="line">cat: patc.log: 没有那个文件或目录</div><div class="line">[root@localhost test3]<span class="comment"># cat patch.log </span></div><div class="line">--- log2013.log 2012-12-07 16:36:26.000000000 +0800</div><div class="line">+++ log2014.log 2012-12-07 18:01:54.000000000 +0800</div><div class="line">@@ -1,10 +1,12 @@</div><div class="line"> 2013-01</div><div class="line"> 2013-02</div><div class="line">-2013-03</div><div class="line">+2014-03</div><div class="line"> 2013-04</div><div class="line"> 2013-05</div><div class="line"> 2013-06</div><div class="line"> 2013-07</div><div class="line">-2013-08</div><div class="line">+2013-07</div><div class="line"> 2013-09</div><div class="line"> 2013-10</div><div class="line">+2013-11</div><div class="line">+2013-12[root@localhost test3]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例7：打补丁"><a href="#实例7：打补丁" class="headerlink" title="实例7：打补丁"></a>实例7：打补丁</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">[root@localhost test3]<span class="comment"># cat log2013.log</span></div><div class="line">2013-01</div><div class="line">2013-02</div><div class="line">2013-03</div><div class="line">2013-04</div><div class="line">2013-05</div><div class="line">2013-06</div><div class="line">2013-07</div><div class="line">2013-08</div><div class="line">2013-09</div><div class="line">2013-10[root@localhost test3]<span class="comment"># patch log2013.log patch.log </span></div><div class="line">patching file log2013.log</div><div class="line">[root@localhost test3]<span class="comment"># </span></div><div class="line">[root@localhost test3]<span class="comment"># cat log2013.log </span></div><div class="line">2013-01</div><div class="line">2013-02</div><div class="line">2014-03</div><div class="line">2013-04</div><div class="line">2013-05</div><div class="line">2013-06</div><div class="line">2013-07</div><div class="line">2013-07</div><div class="line">2013-09</div><div class="line">2013-10</div><div class="line">2013-11</div><div class="line">2013-12[root@localhost test3]<span class="comment">#</span></div></pre></td></tr></table></figure>
	

	
		<span class="different-posts"><a href="/2017/10/12/2. Linux 命令/38. Linux 命令- diff/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
